package com.ztools.pc.controller.sys;

import cn.hutool.json.JSONObject;
import com.ztools.api.service.wx.WxConfigService;
import com.ztools.common.model.pc.bo.wx.WxConfigInfoBo;
import com.ztools.common.util.common.Result;
import org.apache.dubbo.config.annotation.Reference;
import org.springframework.web.bind.annotation.*;

import java.util.ArrayList;

/**
 * @Author: seeTools
 * @Date: 2023/6/21  16:30
 * @Version 1.0
 */
@RestController
@RequestMapping("/sys/wx/config")
public class WxConfigController {

    @Reference(version = "1.0", check = false, timeout = 3000)
    private WxConfigService wxConfigService;


    @GetMapping("/getWxSetInfoList")
    public Result getWxSetInfoList() {
        ArrayList<WxConfigInfoBo> wxConfigInfoBos = new ArrayList<>();
        WxConfigInfoBo wxConfigInfoResp = WxConfigInfoBo.builder()
                .mchId(1)
                .name("星火校园")
                .wxUrl(wxConfigService.getWxServerUrl())
                .appId(wxConfigService.getWxServerAppId())
                .build();
        wxConfigInfoBos.add(wxConfigInfoResp);
        return Result.success().data(wxConfigInfoBos);
    }

    @GetMapping("/getMenu")
    public Result getMenu() {
        return wxConfigService.getMenu();
    }

    @PostMapping("/menuJson")
    public Result createMenuByJson(@RequestBody JSONObject params) {
        return wxConfigService.createMenuByJson(params);
    }
}
